package gmusic.ma.bo;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;

import algutil.date.ConversionDate;

public class DemandeChargement implements Serializable {

	public static final String TO_LOAD = "TO LOAD";
	public static final String LOADING = "LOADING";
	public static final String LOADED = "LOADED";
	public static final String SOURCE_NEW = "NEW";
	public static final String SOURCE_MAJ_AUTO = "MAJ_AUTO";
	public static final String SOURCE_MAJ_MANUELLE = "MAJ_MANUELLE";

	private int id;

	private long amaid;

	public static final String sourceColumnName = "source";
	private String source = null;

	private ArtistMABean artist;

	private int priorite;

	public static final String prioriteColumnName = "priorite";

	private String statut;

	private int nbReleasesToLoad;

	private int nbAjoutReleases;

	private int nbAjoutTracks;

	private Calendar creationDate;

	public static final String creationDateColumnName = "creation_date";

	private Calendar lastUpdateDate;

	public static final String lastUpdateDateColumnName = "last_update_date";

	public DemandeChargement(ResultSet rs) throws SQLException {
		setId(rs.getInt("id"));
		setAmaid(rs.getLong("amaid"));
		setSource(rs.getString(sourceColumnName));
		setPriorite(rs.getInt(prioriteColumnName));
		setStatut(rs.getString("statut"));
		setNbReleasesToLoad(rs.getInt("nb_releases_to_load"));
		setNbAjoutReleases(rs.getInt("nb_ajout_releases"));
		setNbAjoutTracks(rs.getInt("nb_ajout_tracks"));
		setCreationDate(ConversionDate.utilDate2Calendar(rs
				.getDate(creationDateColumnName)));
		setLastUpdateDate(ConversionDate.utilDate2Calendar(rs
				.getDate(lastUpdateDateColumnName)));
	}

	public DemandeChargement(long amaid) {
		this.amaid = amaid;
		statut = TO_LOAD;
		priorite = 0;
	}

	public DemandeChargement(long amaid, String source) {
		this.amaid = amaid;
		statut = TO_LOAD;
		priorite = 0;
		this.source = source;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public long getAmaid() {
		return amaid;
	}

	public void setAmaid(long amaid) {
		this.amaid = amaid;
	}

	public int getPriorite() {
		return priorite;
	}

	public void setPriorite(int priorite) {
		this.priorite = priorite;
	}

	public String getStatut() {
		return statut;
	}

	public void setStatut(String statut) {
		this.statut = statut;
	}

	public int getNbAjoutReleases() {
		return nbAjoutReleases;
	}

	public void setNbAjoutReleases(int nbAjoutReleases) {
		this.nbAjoutReleases = nbAjoutReleases;
	}

	public int getNbAjoutTracks() {
		return nbAjoutTracks;
	}

	public void setNbAjoutTracks(int nbAjoutTracks) {
		this.nbAjoutTracks = nbAjoutTracks;
	}

	public Calendar getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Calendar creationDate) {
		this.creationDate = creationDate;
	}

	public ArtistMABean getArtist() {
		return artist;
	}

	public void setArtist(ArtistMABean artist) {
		this.artist = artist;
	}

	public int getNbReleasesToLoad() {
		return nbReleasesToLoad;
	}

	public void setNbReleasesToLoad(int nbReleasesToLoad) {
		this.nbReleasesToLoad = nbReleasesToLoad;
	}

	public Calendar getLastUpdateDate() {
		return lastUpdateDate;
	}

	public void setLastUpdateDate(Calendar lastUpdateDate) {
		this.lastUpdateDate = lastUpdateDate;
	}

	public String toString() {
		// TODO
		return "DEM [" + statut + ";" + amaid + "]";
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}
}
